Shut down a11y when an app shuts down
authorWilliam Jon McCann <jmccann@redhat.com>
Fri, 14 Sep 2012 18:12:36 +0000 (14:12 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 16 Sep 2012 23:31:23 +0000 (19:31 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=684076

gtk/a11y/gail.c
gtk/a11y/gailutil.c
gtk/a11y/gailutil.h
gtk/gtkapplication.c
gtk/gtkmain.c

index ff8450ac04040c4e67b9847dde6d5016690a2826..82c657e335f851430038f3655da893d5770078c8 100644 (file)
@@ -76,6 +76,7 @@ static GtkWidget* focus_before_menu = NULL;
 static guint focus_notify_handler = 0;    
 static guint focus_tracker_id = 0;
 static GQuark quark_focus_object = 0;
+static int initialized = FALSE;
 
 static AtkObject*
 gail_get_accessible_for_widget (GtkWidget *widget,
@@ -794,10 +795,25 @@ gail_set_focus_object (AtkObject *focus_obj,
     }
 }
 
+void
+_gtk_accessibility_shutdown (void)
+{
+  if (!initialized)
+    return;
+
+  initialized = FALSE;
+
+  g_clear_object (&atk_misc_instance);
+
+#ifdef GDK_WINDOWING_X11
+  atk_bridge_adaptor_cleanup ();
+#endif
+  _gail_util_uninstall ();
+}
+
 void
 _gtk_accessibility_init (void)
 {
-  static int initialized = FALSE;
 
   if (initialized)
     return;
index 7cc175a89b36055eaa12fb4165deb388831f1f4b..0dce3a877f61ceb2112e49121a0c154d1f27b804 100644 (file)
@@ -206,6 +206,17 @@ do_window_event_initialization (void)
                     (GCallback) window_removed, NULL);
 }
 
+static void
+undo_window_event_initialization (void)
+{
+  AtkObject *root;
+
+  root = atk_get_root ();
+
+  g_signal_handlers_disconnect_by_func (root, (GCallback) window_added, NULL);
+  g_signal_handlers_disconnect_by_func (root, (GCallback) window_removed, NULL);
+}
+
 static AtkKeyEventStruct *
 atk_key_event_from_gdk_event_key (GdkEventKey *key)
 {
@@ -341,6 +352,12 @@ gail_util_get_toolkit_version (void)
   return GTK_VERSION;
 }
 
+void
+_gail_util_uninstall (void)
+{
+  undo_window_event_initialization ();
+}
+
 void
 _gail_util_install (void)
 {
index 9c3977da969cb044fb1d95532efc7d717578b591..f89d1d672f9d6e83e78cd8c5a925c9cb3aba7888 100644 (file)
@@ -23,6 +23,7 @@
 G_BEGIN_DECLS
 
 void _gail_util_install (void);
+void _gail_util_uninstall (void);
 
 gboolean  _gail_util_key_snooper (GtkWidget   *the_widget,
                                   GdkEventKey *event);
index e82cda015ecfac7448c1d6a2ffbd9e1cb3ad477f..907b3fe7e1bab2905b9048f3b5486f7cbcfd1d6f 100644 (file)
@@ -47,6 +47,8 @@
 #include <gdk/x11/gdkx.h>
 #endif
 
+extern void _gtk_accessibility_shutdown (void);
+
 /**
  * SECTION:gtkapplication
  * @title: GtkApplication
@@ -425,12 +427,16 @@ gtk_application_shutdown (GApplication *application)
   gtk_application_shutdown_quartz (GTK_APPLICATION (application));
 #endif
 
+  /* Keep this section in sync with gtk_main() */
+
   /* Try storing all clipboard data we have */
   _gtk_clipboard_store_all ();
 
   /* Synchronize the recent manager singleton */
   _gtk_recent_manager_sync ();
 
+  _gtk_accessibility_shutdown ();
+
   G_APPLICATION_CLASS (gtk_application_parent_class)
     ->shutdown (application);
 }
index 56f2226d2f38eb2fdb84d8a1e2f3c93c492755c7..1fd7f192888da909fa3e1799aaaad08516558407 100644 (file)
@@ -671,6 +671,7 @@ gettext_initialization (void)
 
 /* XXX: Remove me after getting rid of gail */
 extern void _gtk_accessibility_init (void);
+extern void _gtk_accessibility_shutdown (void);
 
 static void
 do_post_parse_initialization (int    *argc,
@@ -1172,11 +1173,15 @@ gtk_main (void)
 
   if (gtk_main_loop_level == 0)
     {
+      /* Keep this section in sync with gtk_application_shutdown() */
+
       /* Try storing all clipboard data we have */
       _gtk_clipboard_store_all ();
 
       /* Synchronize the recent manager singleton */
       _gtk_recent_manager_sync ();
+
+      _gtk_accessibility_shutdown ();
     }
 }